/**
 * iWeb2GooglePages - Converts export iWeb content and uploads it to GPs.
 * Copyright (C) 2008 Will Droste
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
package org.iweb2gps;

import static org.jdesktop.application.Application.getInstance;

import java.awt.Font;

import javax.swing.ActionMap;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.WindowConstants;

import net.miginfocom.swing.MigLayout;

import org.jdesktop.application.Action;
import org.jdesktop.application.ApplicationContext;
import org.jdesktop.application.ResourceMap;

@SuppressWarnings("serial")
public class AboutBox extends JDialog {

    private JButton closeButton;

    public AboutBox(java.awt.Frame parent) {
        super(parent);
        initComponents();
        getRootPane().setDefaultButton(closeButton);
    }

    @Action public void closeAboutBox() {
        setVisible(false);
    }

    private void initComponents() {
        
        ApplicationContext ctx = getInstance(App.class).getContext();
        
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        ResourceMap resourceMap = ctx.getResourceMap(AboutBox.class);
        setTitle(resourceMap.getString("title")); 
        setModal(true);
        setName("aboutBox"); 
        setResizable(false);
        
        // setup layout manager..
        setLayout(new MigLayout("", "[left]"));

        JLabel imageLabel = new JLabel();
        imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); 
        imageLabel.setName("imageLabel"); 
        add(imageLabel, "spany, wrap");

        JLabel appTitleLabel = new JLabel();
        appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | Font.BOLD, appTitleLabel.getFont().getSize()+4));
        appTitleLabel.setText(resourceMap.getString("Application.title")); 
        appTitleLabel.setName("appTitleLabel");
        add(appTitleLabel, "spanx, wrap");

        JLabel appDescLabel = new JLabel();
        appDescLabel.setText(resourceMap.getString("appDescLabel.text")); 
        appDescLabel.setName("appDescLabel");
        add(appDescLabel, "span, wrap");

        JLabel versionLabel = new JLabel();
        versionLabel.setFont(versionLabel.getFont().deriveFont(versionLabel.getFont().getStyle() | Font.BOLD));
        versionLabel.setText(resourceMap.getString("versionLabel.text")); 
        versionLabel.setName("versionLabel");
        add(versionLabel);

        JLabel appVersionLabel = new JLabel();
        appVersionLabel.setText(resourceMap.getString("Application.version")); 
        appVersionLabel.setName("appVersionLabel");
        add(appVersionLabel, "wrap");

        JLabel vendorLabel = new JLabel();
        vendorLabel.setFont(vendorLabel.getFont().deriveFont(vendorLabel.getFont().getStyle() | Font.BOLD));
        vendorLabel.setText(resourceMap.getString("vendorLabel.text")); 
        vendorLabel.setName("vendorLabel");
        add(vendorLabel);

        JLabel appVendorLabel = new JLabel();
        appVendorLabel.setText(resourceMap.getString("Application.vendor")); 
        appVendorLabel.setName("appVendorLabel");
        add(appVendorLabel, "wrap");

        JLabel homepageLabel = new JLabel();
        homepageLabel.setFont(homepageLabel.getFont().deriveFont(homepageLabel.getFont().getStyle() | Font.BOLD));
        homepageLabel.setText(resourceMap.getString("homepageLabel.text")); 
        homepageLabel.setName("homepageLabel"); 
        add(homepageLabel);

        JLabel appHomepageLabel = new JLabel();
        appHomepageLabel.setText(resourceMap.getString("Application.homepage")); 
        appHomepageLabel.setName("appHomepageLabel");
        add(appHomepageLabel, "wrap");

        ActionMap actionMap = ctx.getActionMap(AboutBox.class, this);
        closeButton = new JButton();
        closeButton.setAction(actionMap.get("closeAboutBox")); 
        closeButton.setName("closeButton");
        add(closeButton, "span, right");
       
        pack();
    }
}
